<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String callback = request.getParameter("callback");
	String isShow = request.getParameter("isShow") == null ? "" : request.getParameter("isShow");
	String invoice_type = request.getParameter("invoice_type") == null ? "0" : request.getParameter("invoice_type");
	String xm_id = request.getParameter("xm_id") == null ? "" : request.getParameter("xm_id");
	String rec_id = request.getParameter("rec_id") == null ? "" : request.getParameter("rec_id");
	String ticket = request.getParameter("ticket") == null ? "" : request.getParameter("ticket");
	String dept_id = request.getParameter("dept_id") == null ? "" : request.getParameter("dept_id");
	String dept = request.getParameter("dept_name") == null ? "" : request.getParameter("dept_name");
	String xm_code = request.getParameter("xm_code") == null ? "" : request.getParameter("xm_code");
	String xm_name = request.getParameter("xm_name") == null ? "" : request.getParameter("xm_name");
	String customer_id = request.getParameter("customer_id") == null ? "" : request.getParameter("customer_id");
	String customer = request.getParameter("customer") == null ? "" : request.getParameter("customer");
	String id = request.getParameter("id") == null ? "" : request.getParameter("id");
	Map<String, Object> sessionMap = (Map<String, Object>) session.getAttribute("LOGIN_USER");
	String person_id = String.valueOf(sessionMap.get("id"));
	String person = String.valueOf(sessionMap.get("truename"));
	boolean isAdd = "".equals(id);
    int flag = 0;
    if(!isAdd){
    	flag = 1;
    }
%>
<html>
	<head>
		<title><%=isAdd?"新建项目开票":"编辑项目开票" %></title>
		<link href="<%=contextPath%>/public/css/smart_wizard_vertical.css" rel="stylesheet"	type="text/css">
		<script type="text/javascript" src="<%=contextPath %>/public/js/extendTwo.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/public/js/jquery.smartWizard.js"></script>
		<link  rel="stylesheet"  href  ="<%=contextPath%>/public/swfupload/css/swfupload.css">
		  <script  type="text/javascript"  src="<%=contextPath%>/core/js/datastructs.js"  ></script>
			<script  type="text/javascript"  src="<%=contextPath%>/core/js/sys.js"  ></script>
			<script  type="text/javascript"  src="<%=contextPath%>/core/js/prototype.js"  ></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/attachMenu.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/public/swfupload/js/Menu.js"></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/fileprogress.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/handlers.js"  ></script>
		<script  type="text/javascript"  src="<%=contextPath%>/public/swfupload/js/swfupload.queue.js"  ></script>
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
			}
		</style>
	<script type="text/javascript">
		var lastIndex;
		var dept_id; 
		jQuery(function(){
			jQuery("#searchValue").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
	   	}); 
			jQuery('#invoice_type').val('<%=invoice_type%>');
			if('<%=flag%>' == 1){
				jQuery('#ff').form({
				onLoadSuccess:function(){
					queueCompleteOver();
				     jQuery('#person').val(jQuery('#creator').val());
				     jQuery.ajax({
					    	type:'POST',
					    	url:'<%=contextPath %>/springMVC/xm/getAlreadyOutInvoice?xm_id='+jQuery('#xm_id').val(),
					    	success:function(rtJson){
					    		jQuery("#already_out_invoice").numberbox('setValue',rtJson);
					    	}
					    });
				}
			});
		   jQuery('#ff').form('load','<%=contextPath%>/springMVC/xmFinance/getXMInvoiceById?id=<%=id%>');

			}
			jQuery("#tb1").hide();
	       jQuery('#table').datagrid({
	         	url:contextPath+"/springMVC/xmFinance/getXMInvoiceDetail?id=<%=request.getParameter("id")%>",
				rownumbers:true,
				fitColumns:true,
				frozenColumns:[[
					{field:'ck',checkbox:true},
				    {title:'分包商id',field:'worker_id',hidden:true}
				]],
				columns:[[
					{title:'分包商名称',field:'worker_company',width:250,align:'center',editor:{
						type:'combogrid',
						options:{
							url: '<%=contextPath %>/springMVC/xm/listPageWorker',
						    panelWidth:750,
						    panelHeight:355,
						    rownumbers:true,
						    onBeforeLoad:function(param){
						    	param.xm_id = jQuery('#xm_id').val();
						    },
						    fitColumns:true,
						    columns: [[  
						       {field:'id',title:'主键',hidden:true},  
						       {field:'worker_company',title:'分包商',width:200,align:'center'},
						       {field:'type_id',title:'类型',width:200,align:'center',formatter:function(value,rowData,rowIndex){
									if(value==0){
										return "内部班组";
									}else if(value==1){
										return "外部施工队";
									}
									return "未知";
								}},
							   {field:'budget',title:'分包预算',width:100,align:'center'},
						       {field:'worker_person',title:'负责人',width:100,align:'center'},
						       {field:'contact',title:'联系方式',width:150,align:'center'}
						    ]],
						    pageList : [10,50,100],  
							pagination:true,
							toolbar:'#tb1',
							onClickRow:function(rowIndex,rowData){
								if(checkSameWorker(rowData,jQuery('#table').datagrid('getData').rows)){
									var pRow = jQuery('#table').datagrid('getRows')[lastIndex];
									pRow.worker_id = rowData.id;
									pRow.worker_company = rowData.worker_company;
									pRow.worker_person = rowData.worker_person;
									pRow.pre_money=rowData.budget;
									jQuery('#table').datagrid('getData').rows[lastIndex]=pRow;
									var data = jQuery('#table').datagrid('getData');
									jQuery('#table').datagrid('loadData',data);
									
									jQuery('#table').datagrid('endEdit', lastIndex);
									jQuery('#table').datagrid('beginEdit', lastIndex);
									
									//lastIndex =-1;
								}else{
									jQuery.messager.alert("提示","选择的分包商已经存在");
								}
							}
						}
					}},
					{title:'负责人',field:'worker_person',width:150,align:'center'},
					<%if(isAdd){%>
					{title:'预算金额',field:'pre_money',width:150,align:'center'},
					<%}else{%>
					{title:'预算金额',field:'pre_money',width:150,align:'center',formatter:function(value,row,index){
						if(value == undefined){
							var xm_id = jQuery('#xm_id').val();
							var worker_id = row.worker_id;
							jQuery.ajax({
								type:'POST',
								async:false,
								url:'<%=contextPath %>/springMVC/xm/getWorkerBugdet?xm_id='+xm_id+'&worker_id='+worker_id,
								success:function(rtJson){
									row.pre_money = rtJson;
								}
							});
						}
						return row.pre_money;
					}},
					<%}%>
					{title:'开票额(元)',field:'out_invoice',width:200,align:'center',
						editor:{
							type:'numberbox',
							options:{
								 min:0,    
	    						 precision:2 
							}
					}},
					{title:'税金(元)',field:'tax',hidden:true,align:'center',editor:{
						type:'numberbox',
						options:{
							precision:2
						}
					}},
					{title:'备注',field:'remark',width:200,align:'center',editor:{
						type:'textarea'
					}}
				]],
				onBeforeLoad:function(){
					jQuery(this).datagrid('rejectChanges');
				},
				
				onLoadSuccess:function(data){
				<%if(flag==1){%>
					calTax();
					<%}%>
				},
				
				onClickCell:function(rowIndex,field,value){
					if (lastIndex != rowIndex){
						jQuery('#table').datagrid('endEdit', lastIndex);
						jQuery('#table').datagrid('beginEdit', rowIndex);
						var ed = jQuery('#table').datagrid('getEditor', {index:rowIndex,field:field});
						if(ed == null){
							ed = jQuery('#table').datagrid('getEditor', {index:rowIndex,field:'out_invoice'});
						}
						jQuery(ed.target).select();
					}
					lastIndex = rowIndex;
				},
				toolbar:[
					{
						id:'add',
						text:'选择分包商',
						disabled:false,
						iconCls:'icon-add',
						handler:function(){
							addRow();
						}
					},'-',{
					id:'save',
					text:'保存修改',
					disabled:false,
					iconCls:'icon-save',
					handler:function(){
						jQuery('#table').datagrid('acceptChanges');
						lastIndex =-1;
						acountTax();
					}
					},'-',{
					id:'delete',
					text:'删除',
					disabled:false,
					iconCls:'icon-remove',
					handler:function(){
						jQuery('#table').datagrid('acceptChanges');
						lastIndex =-1;
						var rows = jQuery('#table').datagrid('getSelections');
						if (rows.length > 0){
							for(var i=0;i<rows.length;i++){
								var row = rows[i];
								var index = jQuery('#table').datagrid('getRowIndex', row);
								jQuery('#table').datagrid('deleteRow', index);
							}
						}
						var data = jQuery('#table').datagrid('getData');
						jQuery('#table').datagrid('loadData',data);
					}
				}
			   ]
			});
	       var settings = {
				      flash_url : "<%=contextPath%>/public/swfupload/swfupload.swf",
				      upload_url: "<%=contextPath%>/springMVC/fileUpload/fileupload",
				      post_params: {
				    	 "module" : "<%=com.beaut.project.util.StaticData.XM_MODULE%>"
				      },
				      file_size_limit : "100 MB",
				      file_types : "*.*",
				      file_types_description : "All Files",
				      file_upload_limit : 100,
				      file_queue_limit : 0,
				      custom_settings : {
				        uploadArea : "fsUploadArea",
				        progressTarget : "fsUploadProgress",
				        startButtonId : "btnStart",
				        cancelButtonId : "btnCancel"
				      },
				      debug: false,
				      button_image_url: "<%=contextPath%>/public/swfupload/img/uploadx4.gif",
				      button_width: "65",
				      button_height: "29",
				      button_placeholder_id: "spanButtonUpload",
				      button_text: '<span class=\"textUpload\">上传附件</span>',
				      button_text_style: ".textUpload{color:#0000ff;}",
				      button_text_top_padding : 1,
				      button_text_left_padding : 18,
				      button_width: 80,
				      button_height: 20,
				      button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				      button_cursor: SWFUpload.CURSOR.HAND,
				      
				      file_queued_handler : fileQueued,
				      file_queue_error_handler : fileQueueError,
				      file_dialog_complete_handler : fileDialogComplete,
				      upload_start_handler : uploadStart,
				      upload_progress_handler : uploadProgress,
				      upload_error_handler : uploadError,
				      upload_success_handler : uploadSuccessOver,
				      upload_complete_handler : uploadComplete,
				      queue_complete_handler : queueCompleteOver
				    };
				    swfupload = new SWFUpload(settings);
				  
				});
			
		 function uploadSuccessOver(file, serverData){
				  try {
				    var progress = new FileProgress(file, this.customSettings.progressTarget);
				    progress.toggleCancel(false);
				    var json = null;
				    json = serverData.evalJSON();
				    if(json.rtState=="1") {
				       progress.setError();
				       progress.setStatus("上传失败");
				    } else {
				       if($('attachmentId').value!=null && $('attachmentId').value!=""){
				    	 $('attachmentId').value += ',' + json.rtData.attachmentId;
				       } 
				       else{
				    	   $('attachmentId').value = json.rtData.attachmentId;
				       }
				       if($('attachmentName').value!=null && $('attachmentName').value!=""){
				    	 $('attachmentName').value += '*' + json.rtData.attachmentName;
				       } 
				       else{
				    	   $('attachmentName').value = json.rtData.attachmentName;
				       }
				    }
				  } catch (ex) {
				    this.debug(ex);
				  }
		}
		function queueCompleteOver(){
			var attachmentIds = $("attachmentId").value;
		    var attachmentNames = $("attachmentName").value;
		    if(attachmentIds){
		      jQuery('#attaTr').show();
	       	  jQuery('#fsUploadArea').hide();
	       	  attachMenuUtil("showAtt",null,null,attachmentNames,attachmentIds,false,'attach');
		    }
		 }
				 
		  function deleteAttachment(attachmentId,attachmentName){
			  var attrIds = $("attachmentId").value;
		    var attrNames = $("attachmentName").value;
		     var attrIdArrays = attrIds.split(",");
			  var attrNameArrays = attrNames.split("*");
			 var idArray = new Array();
			 var nameArray = new Array();
			 
			 for(var i=0;i<attrIdArrays.length;i++){
				 if(attrIdArrays[i] != attachmentId){
					 idArray.push(attrIdArrays[i]);
					 nameArray.push(attrNameArrays[i]);
				 }
			 }
			 $("attachmentId").value = idArray.join(",");
			 $("attachmentName").value = nameArray.join("*");
			 if($("attachmentId").value == ""){
				 jQuery('#attaTr').hide();
			 }
		  }
		  

			function checkSameWorker(rowData,rows){
				if (rows.length > 0){
					for(var i=0;i<rows.length;i++){
						if(rows[i].worker_id==rowData.id){
							return false;
						}
					}
				}
				return true;
			}
			function acountTax(){
				var jsondata=jQuery("#table").datagrid("getData");
				var workers_out_invoice=0;
				for(var i=0;i<jsondata.total;i++){
					var index = jQuery("#table").datagrid("getRowIndex",jsondata.rows[i])+1;
					if(jsondata.rows[i].worker_company == null || jsondata.rows[i].worker_company == ""){
						jQuery.messager.alert('提示','第'+index+'行未选择产品！');
						return ;
					}else if(jsondata.rows[i].out_invoice == null || jsondata.rows[i].out_invoice <= 0){
						jQuery.messager.alert('提示','第'+index+'行数量填写不正确！');
						return ;
					}
					else{
						workers_out_invoice=parseFloat(workers_out_invoice)+parseFloat(jsondata.rows[i].out_invoice);
					}
				}
				var account_receivable=jQuery("#account_receivable").val();
				var tax_rate=jQuery("#tax_rate").val();
				var tax = Math.round(((parseFloat(account_receivable)-parseFloat(workers_out_invoice))*parseFloat(tax_rate))*Math.pow(10,2))/Math.pow(10,2);
				jQuery('#company_tax').numberbox('setValue',tax);
			}
			
		function acountTax(){
			var jsondata=jQuery("#table").datagrid("getData");
			var workers_out_invoice=0;
			for(var i=0;i<jsondata.total;i++){
				var index = jQuery("#table").datagrid("getRowIndex",jsondata.rows[i])+1;
				if(jsondata.rows[i].worker_company == null || jsondata.rows[i].worker_company == ""){
					jQuery.messager.alert('提示','第'+index+'行未选择产品！');
					return ;
				}else if(jsondata.rows[i].out_invoice == null || jsondata.rows[i].out_invoice < 0){
					jQuery.messager.alert('提示','第'+index+'行数量填写不正确！');
					return ;
				}
				else{
					workers_out_invoice=parseFloat(workers_out_invoice)+parseFloat(jsondata.rows[i].out_invoice);
				}
			}
			var account_receivable=jQuery("#account_receivable").val();
			var tax_rate=jQuery("#tax_rate").val();
			var tax = Math.round(((parseFloat(account_receivable)-parseFloat(workers_out_invoice))*parseFloat(tax_rate))*Math.pow(10,2))/Math.pow(10,2);
			jQuery('#company_tax').numberbox('setValue',tax);
		}
		function calTax(){
			var jsondata=jQuery("#table").datagrid("getData");
			var workers_out_invoice=0;
			for(var i=0;i<jsondata.total;i++){
				if(jsondata.rows[i].out_invoice == null || jsondata.rows[i].out_invoice == ""){
					continue;
				}
				workers_out_invoice=parseFloat(workers_out_invoice)+parseFloat(jsondata.rows[i].out_invoice);
			}
			var account_receivable=jQuery("#account_receivable").val();
			var company_tax=jQuery("#company_tax").val();
			var tax_rate=((parseFloat(company_tax)/(parseFloat(account_receivable)-parseFloat(workers_out_invoice))));
			jQuery("#tax_rate").numberbox('setValue',tax_rate);
		}
		function addRow(){
			if(jQuery('#xm_id').val() == null || jQuery('#xm_id').val()==''){
				jQuery.messager.alert('提示','请先选择项目');
				return;
			}
			jQuery('#table').datagrid('endEdit', lastIndex);
			jQuery('#table').datagrid('appendRow',{
			});
			var data = jQuery('#table').datagrid('getData');
			jQuery('#table').datagrid('loadData',data);
			lastIndex = jQuery('#table').datagrid('getRows').length-1;
			jQuery('#table').datagrid('selectRow', lastIndex);
			jQuery('#table').datagrid('beginEdit', lastIndex);
		}
		
		function addXMInvoiceRequest(obj){
			//自动提交数据
			jQuery('#table').datagrid('acceptChanges');
			lastIndex =-1;
			//自动提交数据
			var xm_id =jQuery("#xm_id").val();	
			var xm_name=jQuery("#xm_name").val();	
			var xm_code=jQuery("#xm_code").val();
			 var attachmentId = jQuery('#attachmentId').val();
			var invoice_title=encodeURIComponent(jQuery("#invoice_title").val());
			var remark=encodeURIComponent(jQuery('#remark').val());
			if(!checkNullOREmpty(xm_id,'项目为必填项')){return;}
			if(!checkNullOREmpty(invoice_title,'抬头为必填项')){return;}
			var customer_id =jQuery("#customer_id").val();		
			var invoice_type =jQuery("#invoice_type").val();		
			var dept =jQuery("#dept_name").val();	
			var customer =jQuery("#customer").val();	
			var account_receivable=jQuery("#account_receivable").val();
			var company_out_invoice = 0;
			var alarm_time=jQuery("#alarm_time").datebox('getValue');
			var workers="";
			var jsondata=jQuery("#table").datagrid("getData");
			var workers_out_invoice=0;
			for(var i=0;i<jsondata.total;i++){
				if(workers!=""){
					workers+=";";
				}
				workers+=jsonToStr(jsondata.rows[i]);
				var index = jQuery("#table").datagrid("getRowIndex",jsondata.rows[i])+1;
				if(jsondata.rows[i].worker_company == null || jsondata.rows[i].worker_company == ""){
					jQuery.messager.alert('提示','第'+index+'行未选择产品！');
					return ;
				}else if(jsondata.rows[i].out_invoice == null || jsondata.rows[i].out_invoice < 0){
					jQuery.messager.alert('提示','第'+index+'行数量填写不正确！');
					return ;
				}
				else{
					workers_out_invoice=parseFloat(workers_out_invoice)+parseFloat(jsondata.rows[i].out_invoice);
					
				}
			}
		    if(parseFloat(workers_out_invoice) > parseFloat(account_receivable)){
		    	jQuery.messager.alert('提示','分包商总金额不能大于开票总额！');
				return ;
		    }
		    var account_receivable=jQuery("#account_receivable").val();
		    var tax_rate=jQuery("#tax_rate").val();
			//var company_tax = Math.round(((parseFloat(account_receivable)-parseFloat(workers_out_invoice))*parseFloat(tax_rate))*Math.pow(10,2))/Math.pow(10,2);
			
			var company_tax =jQuery("#company_tax").numberbox('getValue');
		    var ticket = jQuery("#ticket").val();		
			var flagType=0;
		    <%if("3".equals(isShow)){%>
		    	flagType=1;
		    <%}%>
			var param = "customer_id="+customer_id+"&customer="+customer+"&remark="+remark+"&attachmentId="+attachmentId
			+"&invoice_title="+invoice_title+"&account_receivable="+account_receivable+"&company_out_invoice="+company_out_invoice
			+"&company_tax="+company_tax+"&alarm_time="+alarm_time+"&invoice_type="+invoice_type
			+"&xm_id="+xm_id+"&xm_code="+xm_code+"&xm_name="+xm_name+"&dept_id="+dept_id+"&dept="+dept+"&workers="+workers+"&flagType="+flagType+"&ticket="+ticket+"&rec_id=<%=rec_id%>";
			jQuery(obj).hide();
			jQuery.ajax({
				type:'POST',
				<%=isAdd?"url:'"+contextPath+"/springMVC/xmFinance/addXMInvoice',":"url:'"+contextPath+"/springMVC/xmFinance/updateXMInvoice?id="+id+"',"%>
				data:param,
				dataType:'json',
				success:function(rtJson){
					if(rtJson.rtState == '0'){
						eval('window.opener.<%=callback%>();');
						window.close();
					}
					else{
						jQuery.messager.alert("提示",rtJson.rtMsrg);
					}
					jQuery(obj).show();
				}
			});
		}
		function choseXm(){
				<%if("0".equals(invoice_type)){%>
				//验收后停止进度开票
			var  tempReturnValue= window.open("<%=contextPath %>/springViews/xm/choseMyXM.jsp?statusType=4" ,window,'height=1000, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');

				<%}%>
				<%if("1".equals(invoice_type)){%>
			var  tempReturnValue= window.open("<%=contextPath %>/springViews/xm/choseMyXMEnd.jsp" ,window,'height=1000, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
				<%}%>
		}
		function rtCallBackXmSet(xm_id,xm_code,xm_name,deptId,dept,customer_id,customer){
		    dept_id=deptId;
			jQuery("#xm_id").val(xm_id);
		    jQuery("#xm_name").val(xm_name);
		    jQuery("#xm_code").val(xm_code);
		    jQuery("#dept_name").val(dept);
		    jQuery("#dept_id").val(dept_id);
		    jQuery("#customer_id").val(customer_id);
		    jQuery("#customer").val(customer);
		    jQuery("#invoice_title").val(customer);
		    jQuery.ajax({
		    	type:'POST',
		    	url:'<%=contextPath %>/springMVC/xm/getAlreadyOutInvoice?xm_id='+xm_id,
		    	success:function(rtJson){
		    		jQuery("#already_out_invoice").numberbox('setValue',rtJson);
		    	}
		    });
		}
		function doSearch()
		{
			var searchValue = jQuery('#searchValue').val();
			var type_id = jQuery('#type_id').val();
			jQuery(combogridTarget).combogrid('grid').datagrid('load',{
				searchValue:searchValue,
				type_id:type_id
				});
		}
	</script>
	</head>
	<body>
		<div style="width: 97%;padding-left:10px">
		<form id="ff">
		<input type="hidden" id="creator" name="creator"/>
			<table  style="border-collapse: collapse;" width="100%" border="1px" bordercolor="#0eb83a">
				<tr>
					<td align="right" class="td1" nowrap>项目编号：</td>
					<td class="td2" nowrap>
					<%if("0".equals(invoice_type)){%>
						<input  id="xm_code" name="xm_code" readOnly value="<%=xm_code%>" placeholder="项目验收后停止进度开票">
					<%}else if("1".equals(invoice_type)){%>
						<input  id="xm_code" name="xm_code" readOnly value="<%=xm_code%>" placeholder="项目送审后才能结算开票">
					<%}%>
						<input type="hidden" id="xm_id" name="xm_id" readOnly value="<%=xm_id%>">
					<%if(!"3".equals(isShow)){ %>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:false" onclick="choseXm();"></a>								</td>
					<%} %>
					</td>
					<td align="right" class="td1" nowrap>项目名称：</td>
					<td class="td2" nowrap>
					<%if("0".equals(invoice_type)){%>
						<input  id="xm_name" name="xm_name" readOnly value="<%=xm_name%>" placeholder="项目验收后停止进度开票">
					<%}else if("1".equals(invoice_type)){%>
						<input  id="xm_name" name="xm_name" readOnly value="<%=xm_name%>" placeholder="项目送审后才能结算开票">
					<%}%>
						
					</td>
				</tr>
				<%if(!"3".equals(isShow)){ %>
				<tr>
				
					<td align="right" class="td1" nowrap>项目部门：</td>
					<td class="td2" nowrap>
						<input  id="dept_name" name="dept_name" readOnly value="<%=dept%>">
						<input  type="hidden" id="dept_id" name="dept_id" readOnly value="<%=dept_id%>">
					</td>
					<td align="right" class="td1" nowrap>经办人：</td>
					<td class="td2" nowrap>
						<input  id="person" name="person" readOnly value="<%=person%>">
					</td>
				</tr>
				<tr>
					<td align="right" class="td1" nowrap>对应客户：</td>
					<td class="td2" nowrap>
						<input  id="customer" name="customer" readOnly value="<%=customer%>">
						<input  type="hidden" id="customer_id" name="customer_id" readOnly value="<%=customer_id%>">
					</td>
					<td align="right" class="td1" nowrap>开票类型：</td>
					<td class="td2" nowrap>
						<select id="invoice_type" name="invoice_type" disabled="disabled">
							<option value="0">进度开票</option>
							<option value="1">结算开票</option>
						</select>
					</td>
				</tr>
				<tr>
			        <td align="right" class="td1" nowrap>发票抬头：</td>
					<td class="td2" nowrap >
						<input  id="invoice_title" style="width:90%"  name="invoice_title">
					</td>
					 <td align="right" class="td1" nowrap>发票票号：</td>
					<td class="td2" nowrap  >
						<input  id="ticket" style="width:90%"  name="ticket" value="<%=ticket %>"><span style="color:red">*</span>
					</td>
				</tr>
				<tr>	
			        <td align="right" class="td1" nowrap>已开票额：</td>
					<td class="td2" nowrap>
						<input  id="already_out_invoice" name="already_out_invoice" class="easyui-numberbox" data-options="disabled:true">
					</td>
			        <td align="right" class="td1" nowrap>本次开票额：</td>
					<td class="td2" nowrap>
						<input  id="account_receivable" name="account_receivable" class="easyui-numberbox" data-options="min:0,precision:2" value="0">
					</td>
				<tr>
				<tr>
			       <td align="right" class="td1" nowrap>调整税率：</td>
					<td class="td2" colspan="3" nowrap>
						<input  id="tax_rate" name="tax_rate" class="easyui-numberbox"  data-options="precision:5"><a href="javascript:acountTax()">计算税金</a>(默认税率为0.0339,可以自行调整)。
					</td>
				    	
				</tr>
				<tr>
			       <td align="right" class="td1" nowrap>税金：</td>
					<td class="td2" nowrap>
						<input  id="company_tax" name="company_tax" class="easyui-numberbox" data-options="precision:2">
					</td>
				    <td align="right" class="td1" nowrap>收款提醒时间：</td>
					<td class="td2" nowrap >
						<input  id="alarm_time" name="alarm_time" class="easyui-datebox"/>
					</td>		
				</tr>
				<tr style="display:none;">
					<td align="right" class="td1" nowrap>公司承担金额：</td>
					<td class="td2" nowrap>
						<input  id="company_out_invoice" name="company_out_invoice"  class="easyui-numberbox" data-options="min:0,precision:2" value="0">
					</td>
		      	</tr>
		      	
				<tr>
					<td align="right" class="td1" nowrap>摘要：</td>
					<td class="td2" nowrap colspan='3'>
						<textarea  id="remark" name="remark" rows="6" style="width: 100%"></textarea>
					</td>
				</tr>
				<%} else{%>
				<tr>
				
					<td align="right" class="td1" nowrap>项目部门：</td>
					<td class="td2" nowrap>
						<input  id="dept_name" name="dept_name" readOnly value="<%=dept%>">
						<input  type="hidden" id="dept_id" name="dept_id"  disabled="disabled" readOnly value="<%=dept_id%>">
					</td>
					<td align="right" class="td1" nowrap>经办人：</td>
					<td class="td2" nowrap>
						<input  id="person" name="person" readOnly  disabled="disabled" value="<%=person%>">
					</td>
				</tr>
				<tr>
					<td align="right" class="td1" nowrap>对应客户：</td>
					<td class="td2" nowrap>
						<input  id="customer" name="customer" readOnly value="<%=customer%>">
						<input  type="hidden" id="customer_id" name="customer_id"  disabled="disabled" readOnly value="<%=customer_id%>">
					</td>
					<td align="right" class="td1" nowrap>开票类型：</td>
					<td class="td2" nowrap>
						<select id="invoice_type" name="invoice_type" disabled="disabled">
							<option value="0">进度开票</option>
							<option value="1">结算开票</option>
						</select>
					</td>
				</tr>
				<tr>
			        <td align="right" class="td1" nowrap>发票抬头：</td>
					<td class="td2" nowrap  >
						<input  id="invoice_title" style="width:90%"  name="invoice_title"  disabled="disabled">
					</td>
					 <td align="right" class="td1" nowrap>发票票号：</td>
					<td class="td2" nowrap  >
						<input  id="ticket" style="width:90%"  name="ticket" value="<%=ticket %>"><span style="color:red">*</span>
					</td>
				</tr>
				<tr>	
			        <td align="right" class="td1" nowrap>已开票额：</td>
					<td class="td2" nowrap>
						<input  id="already_out_invoice" name="already_out_invoice" class="easyui-numberbox" data-options="disabled:true">
					</td>
			        <td align="right" class="td1" nowrap>本次开票额：</td>
					<td class="td2" nowrap>
						<input  id="account_receivable" name="account_receivable" class="easyui-numberbox" data-options="min:0,precision:2" value="0">
					</td>
				<tr>
				<tr>
			       <td align="right" class="td1" nowrap>调整税率：</td>
					<td class="td2" colspan="3" nowrap>
						<input  id="tax_rate" name="tax_rate" class="easyui-numberbox"  data-options="precision:5"><a href="javascript:acountTax()">计算税金</a>(默认税率为0.0339,可以自行调整)。
					</td>
				    	
				</tr>
				<tr>
			       <td align="right" class="td1" nowrap>税金：</td>
					<td class="td2" nowrap>
						<input  id="company_tax" name="company_tax" class="easyui-numberbox" data-options="precision:2">
					</td>
				    <td align="right" class="td1" nowrap>收款提醒时间：</td>
					<td class="td2" nowrap >
						<input  id="alarm_time" name="alarm_time" class="easyui-datebox"  disabled="disabled"/>
					</td>		
				</tr>
				<tr style="display:none;">
					<td align="right" class="td1" nowrap>公司承担金额：</td>
					<td class="td2" nowrap>
						<input  id="company_out_invoice" name="company_out_invoice"  class="easyui-numberbox" data-options="disabled:true,min:0,precision:2" value="0">
					</td>
		      	</tr>
		      	
				<tr>
					<td align="right" class="td1" nowrap>摘要：</td>
					<td class="td2" nowrap colspan='3'>
						<textarea  id="remark" name="remark" rows="6" style="width: 100%"  disabled="disabled"></textarea>
					</td>
				</tr>
				
				<%} %>
				<tr id="attaTr" style="display:none">
								      <td nowrap align="right" class="td1">附件明细: </td>
								      <td class="td2"  colspan="3" >
								        <input type="hidden" id="attachmentId" name="attachmentId">
								        <input type="hidden" id="attachmentName" name="attachmentName">
								        <span id="showAtt">
								        </span>
								      </td>
							   	    </tr>
								<tr>
							      <td nowrap align="right" class="td1">附件：</td>
							      <td class="td2"  colspan="3" >
							        	 <div id="fsUploadArea" class="flash" style="width:380px;">
										     <div id="fsUploadProgress"></div>
										     <div>
										       <input type="button" id="btnStart" class="SmallButtonW" value="开始上传" onclick="swfupload.startUpload();" disabled="disabled">&nbsp;&nbsp;
										       <input type="button" id="btnCancel" class="SmallButtonW" value="全部取消" onclick="javascript:swfupload.cancelQueue();jQuery('#fsUploadArea').hide();" disabled="disabled">&nbsp;&nbsp;
										    </div>
									      </div>
									      
										    <div id="attachment1">
									          <span id="spanButtonUpload" title="上传附件"></span>
									        </div>
							      </td>
					   		   </tr>
				<%if(!"1".equals(isShow)||"3".equals(isShow)){ %>
				<tr>
					<td align="right" class="td1" nowrap></td>
					<td class="td2" nowrap colspan='3'>
						<div align="left">
						   
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="addXMInvoiceRequest(this);">提交</a>
							
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:false" onclick="javascript:window.close();">关闭</a>
						</div>
					</td>
				</tr>
				<%} %>
				<tr>
					<td colspan="4"  nowrap>
						<div id="myMsg" style="color:red">*以下选项在审核通过后，会自动在收票管理中增加收票记录。</div>
					</td>
				</tr>			
				<tr>
					<td colspan="4"  nowrap>
						<div id="table"></div>
					</td>
				</tr>
			</table>
			</form>
		</div>
			<div id="tb1" align="right">
							分类：<select id="type_id" class="" name="type_id" style="width:200px;" onchange="doSearch()">   
								     <option value="" selected></option> 
								    <option value="0">内部班组</option>   
								    <option value="1">外部分包商</option>   
								</select>  
							查询条件：<input id="searchValue" name="searchValue" style="width:150px" title="分包商名称或负责人"/>&nbsp;&nbsp;
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
						</div>
	</body>
</html>